//
//  LeftSortsViewController.m
//  BTRIP
//
//  Created by johnbk on 15/11/12.
//  Copyright © 2015年 johnbk. All rights reserved.
//

#import "LeftSortsViewController.h"
#import "AppDelegate.h"
#import "MainPageViewController.h"
#import "GoodShopViewController.h"
#import "TravelTactic_MainViewController.h"
#import "ExperienceViewController.h"
#import "CollectViewController.h"
#import "SearchViewController.h"

@interface LeftSortsViewController ()<UITableViewDataSource, UITableViewDelegate>

@end

@implementation LeftSortsViewController
-(void)dealloc{
	[_tableView release];
	[_array release];
	[super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
	self.array = @[@"推荐",@"好店", @"旅行攻略", @"体验", @"收藏", @"搜索"];
	UIImageView *imageview = [[UIImageView alloc] initWithFrame:self.view.bounds];
	imageview.image = [UIImage imageNamed:@"background"];
	[self.view addSubview:imageview];
	[imageview release];
	
	self.tableView = [[UITableView alloc]init];
	self.tableView.frame = self.view.bounds;
	self.tableView.dataSource = self;
	self.tableView.delegate  = self;
	self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
	[self.view addSubview:self.tableView];
	[self.tableView release];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
	return self.array.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
	static NSString *Identifier = @"CellIdentifier";
	UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:Identifier];
	if (cell == nil) {
		cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Identifier];
	}
	cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
	cell.textLabel.font = [UIFont systemFontOfSize:20.0f];
	cell.backgroundColor = [UIColor clearColor];
	cell.textLabel.textColor = [UIColor whiteColor];
	
	cell.textLabel.text = self.array[indexPath.row];
	return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
	//[tableView deselectRowAtIndexPath:indexPath animated:YES];
	AppDelegate *tempAppDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
	
	[tempAppDelegate.leftSlideVC closeLeftView];//关闭左侧抽屉
	if (indexPath.row == 0) {
		MainPageViewController *mainPageViewController = [[MainPageViewController alloc] init];
		[tempAppDelegate.mainNavigationController pushViewController:mainPageViewController animated:NO];
        [mainPageViewController release];
	}
	else if (indexPath.row == 1){
		GoodShopViewController *goodShopViewController = [[GoodShopViewController alloc]init];
		[tempAppDelegate.mainNavigationController pushViewController:goodShopViewController animated:YES];
        [goodShopViewController release];
    } else if (indexPath.row == 2) {
        TravelTactic_MainViewController *travelTactic_MainViewController = [[TravelTactic_MainViewController alloc] init];
        [tempAppDelegate.mainNavigationController pushViewController:travelTactic_MainViewController animated:YES];
        [travelTactic_MainViewController release];
    }
	else if (indexPath.row == 3){
		ExperienceViewController *experienceController = [[ExperienceViewController alloc]init];
		[tempAppDelegate.mainNavigationController pushViewController:experienceController animated:YES];
		[experienceController release];
    } else if (indexPath.row == 4) {
        CollectViewController *collectVC = [[CollectViewController alloc] init];
        [tempAppDelegate.mainNavigationController pushViewController:collectVC animated:YES];
        [collectVC release];
    } else if (indexPath.row == 5) {
        SearchViewController *searchVC = [[SearchViewController alloc] init];
        [tempAppDelegate.mainNavigationController pushViewController:searchVC animated:YES];
        [searchVC release];
    }
	
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
	return 180;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
	UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.bounds.size.width, 180)];
	view.backgroundColor = [UIColor clearColor];
	return view;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
